package com.ingesup.caribou.client.gui.app;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.LayoutManager;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.text.BadLocationException;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import javax.swing.JLabel;

import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class About extends JDialog {
	private static final long serialVersionUID = -6665609063607371441L;
	private final JPanel contentPanel = new JPanel();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			About dialog = new About(null);
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 * @throws BadLocationException 
	 */
	public About( JFrame parent) throws BadLocationException {
		super(parent);
		
		
		setTitle("A propos");
		setBounds(100, 100, 682, 316);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		JPanel panel_image = new JPanel();
		panel_image.setBounds(0, 0, 664, 103);
		contentPanel.add(panel_image);
		
		JLabel image = new JLabel( new ImageIcon( "ressource\\logoIngesup.png"));
		panel_image.add(image,BorderLayout.CENTER);
		
		JPanel panel_Texte = new JPanel();
		panel_Texte.setBounds(217, 100, 447, 134);
		contentPanel.add(panel_Texte);
		
		JTextPane textPane = new JTextPane();
		textPane.setBackground(SystemColor.control);
		SimpleAttributeSet centrer = new SimpleAttributeSet();
		StyleConstants.setAlignment(centrer, StyleConstants.ALIGN_CENTER);
		StyledDocument doc = textPane.getStyledDocument();
		SimpleAttributeSet style_normal = new SimpleAttributeSet();
		StyleConstants.setFontFamily(style_normal, "Calibri");
		StyleConstants.setFontSize(style_normal, 16);
		
				
		String texte_apropos = "\nProject Caribou\n"+
				"(c) INGESUP TOULOUSE,TREMPLIN 2013.  All rights reserved.\n"+
				"Visit http://www.ingesup.com/";
		
		textPane.setEditable(false);
		
		doc.insertString(doc.getLength(), texte_apropos, style_normal);
		panel_Texte.add(textPane);
		
		
		JPanel panel_logoCar = new JPanel();
		panel_logoCar.setBounds(0, 100, 217, 134);
		contentPanel.add(panel_logoCar);
		
		JLabel logo = new JLabel( new ImageIcon( "ressource\\logoCar.png"));
		panel_logoCar.add(logo,BorderLayout.CENTER);
		
		JPanel labelPane = new JPanel(new GridLayout(2,1));
		
		getContentPane().add(labelPane, BorderLayout.WEST);
		
		final JPanel buttonPane = new JPanel();
		buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
		getContentPane().add(buttonPane, BorderLayout.SOUTH);

		JButton cancelButton = new JButton("Close");
		cancelButton.setActionCommand("Close");
		buttonPane.add(cancelButton);
		cancelButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				dispose();				
			}
		});

		
	}
	
	
}
